Skip to content

Conversation

@FRASTM
Copy link
Contributor

@FRASTM FRASTM commented Feb 6, 2024

Define the MPU attribute to be ATTR_MPU_IO for the qspi region, starting at 0x90000000 of the stm32h7 serie. That will allow XiP on the external NOR flash octo-quad spi.

This change will prepare the XiP on external NOR flash with stm32h7 boards

@FRASTM FRASTM added this to the v3.7.0 milestone Feb 6, 2024
@FRASTM FRASTM marked this pull request as ready for review February 20, 2024 08:40
@FRASTM FRASTM requested a review from erwango as a code owner February 20, 2024 08:40
@zephyrbot zephyrbot added the platform: STM32 ST Micro STM32 label Feb 20, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break #57467 which required a strongly ordered memory.
If this is incompatible, this means we should define 2 different targets ("variants" in hwmv2) which would define different zephyr,memory-attr depending if memory is expected to be used in XIP or storage

Copy link
Contributor Author

@FRASTM FRASTM Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/arch/arm/mpu/arm_mpu_v7m.h
sets the REGION_EXTMEM_ATTR to be STRONGLY_ORDERED_SHAREABLE
And the Memory region shareability and cache policies for the stm32h7 and stm32F7 (AN4839)
defines the 0x80000000-0x9FFFFFFF range Non-shareable Write-through
--> Could this difference explain the pb ?

Screenshot from 2024-02-21 17-58-32

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AN4760 and AN4861 propose to define the entire region as strongly ordered, non-cacheable, no access, execute never (while memory-mapped mode is not enabled). The ATTR_MPU_EXTMEM more or less follows, and it is ok for non-xip targets.

However, with xip, the attributes should be modified or an extra xip region shall be defined inside the extmem region. That region should start at the mapped memory address with the size of the slot.

The xip region attributes might differ for bootloader (region can stay as strongly ordered, non-cacheable, execute never, but require rw access) and application (region follows RM and is defined as normal, non-shareable, and require to execute and read with optional write access).

Some configurations are not defined within current arm_mpu_v7m.

The MPU usage in STM32 with ARM Cortex®-M7 is quite helpful.

Copy link
Contributor Author

@FRASTM FRASTM Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, keeping the ATTR_MPU_EXTMEM for the entire EXTMEM region:
which can be quad-spi or octo-spi depending on the stm32h7x device.

addressable memory space is 0x90000000 - 0x9FFFFFFF
The stm32h7a/b has another external memory area at 0x70000000 - 0x7FFFFFFF

@FRASTM FRASTM force-pushed the stm32h7_region branch 4 times, most recently from 8f30e83 to 0bdad07 Compare March 1, 2024 15:40
Define the MPU attribute to be ATTR_MPU_EXTMEM for the
external region (qspi- or octo-spi NOR flash)
starting at 0x90000000 of the stm32h7 serie.
A XiP region should be Included inside with attribute
ATTR_MPU_IO, to access the external memory in XIP.
The stm32h7a/h7b serie as another external area at 0x70000000.

Signed-off-by: Francois Ramu <[email protected]>
@FRASTM FRASTM force-pushed the stm32h7_region branch 4 times, most recently from f1be475 to 4574c53 Compare March 1, 2024 15:46
@aescolar aescolar merged commit 23750ff into zephyrproject-rtos:main Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants